#ifdef UTIL_PLATFORM_WIN32
#include "lang/String.h"
#include "windows.h"
namespace yzrilyzr_lang{
	bool String::is_local_encoding_utf8(){
		return GetACP() == 65001;  // Windows代码页65001代表UTF-8
	}
	const std::string String::local_to_utf8(const char * paramRegPtr, u_index len)const{
		if(len == 0) return "";

		int wlen=MultiByteToWideChar(CP_ACP, 0, paramRegPtr, len, NULL, 0);
		if(wlen <= 0) return "";

		std::wstring wstr(wlen, 0);
		MultiByteToWideChar(CP_ACP, 0, paramRegPtr, len, &wstr[0], wlen);

		int utf8len=WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wlen, NULL, 0, NULL, NULL);
		if(utf8len <= 0) return "";

		std::string utf8str(utf8len, 0);
		WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wlen, &utf8str[0], utf8len, NULL, NULL);

		return utf8str;
	}
	const std::string String::utf8_to_local(const std::string & utf8_str)const{
		if(utf8_str.empty()) return "";

		int wlen=MultiByteToWideChar(CP_UTF8, 0, utf8_str.c_str(), utf8_str.size(), NULL, 0);
		if(wlen <= 0) return "";

		std::wstring wstr(wlen, 0);
		MultiByteToWideChar(CP_UTF8, 0, utf8_str.c_str(), utf8_str.size(), &wstr[0], wlen);

		int local_len=WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wlen, NULL, 0, NULL, NULL);
		if(local_len <= 0) return "";

		std::string local_str(local_len, 0);
		WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wlen, &local_str[0], local_len, NULL, NULL);

		return local_str;
	}
}
#endif // _WIN32